package Jets.ui
{
   import flash.display.DisplayObjectContainer;
   import flash.events.MouseEvent;
   
   import Jets.ui.skins.SkinStates;
   
   public class JStateButton extends JPushButton
   {
      
	  protected var sel:Boolean = false;
	  
      public function JStateButton(parent:DisplayObjectContainer=null, cx:Number=0, cy:Number=0, text:String="", click:Function=null) 
	  {
         super(parent,cx,cy,text,click);
      }
      
      override protected function onMouseOver(event:MouseEvent) : void 
	  {
         if(this.sel)
         {
            return;
         }
         super.onMouseOver(event);
      }
      
      override protected function onMouseOut(event:MouseEvent) : void 
	  {
         if(this.sel)
         {
            return;
         }
         super.onMouseOut(event);
      }
      
      override protected function onMouseDown(event:MouseEvent) : void 
	  {
         if(this.sel)
         {
            return;
         }
         super.onMouseDown(event);
      }
      
      override protected function onMouseUp(event:MouseEvent) : void 
	  {
         if(this.sel)
         {
            state = SkinStates.SELECTED;
            return;
         }
         super.onMouseUp(event);
      }
      
      public function set selected(value:Boolean) : void 
	  {
         this.sel = value;
         if(this.sel)
         {
            state = SkinStates.SELECTED;
         }
         else
         {
            state = SkinStates.UP;
         }
      }
      
      public function get selected() : Boolean 
	  {
         return this.sel;
      }
   }
}
